package Utils

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

const (
	SUCCESS = 1
	ERROR   = 0
)

// Utils结构体
type Utils struct {
}

func InitUtils() *Utils {
	u := &Utils{}
	return u
}

var c *gin.Context

func (_self *Utils) Success(data interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, map[string]interface{}{
		"code": SUCCESS,
		"msg":  msg,
		"data": data,
	})
}

func (_self *Utils) Error(data interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, map[string]interface{}{
		"code": SUCCESS,
		"msg":  msg,
		"data": nil,
	})
}
